import $http from '../../../servers/http';
import { Result } from '../../schema/Result';
/* 系统配置-TTS厂商管理
---------------------------------------------------------------- */
import { SyntheticTTSVoice, TTSInfo } from '../../schema/TTS';
/**新增TTS厂商 */
export const createTTS = (data: TTSInfo): Promise<any> => {
  return $http.post({
    url: '/icms/ttsmanufacturermanage/ttsmanufacturers',
    data,
  });
};

/**删除TTS厂商 */
export const deleteTTS = (id: number): Promise<Result<null>> => {
  return $http.delete({
    url: `/icms/ttsmanufacturermanage/ttsmanufacturers/${id}`,
  });
};

/**编辑TTS厂商 */
export const modifyTTS = (id: number, data: TTSInfo): Promise<Result<null>> => {
  return $http.put({
    url: `/icms/ttsmanufacturermanage/ttsmanufacturers/${id}`,
    data,
  });
};

/**查询TTS厂商列表 */
export const getTTSList = (data: {
  pageSize: number;
  pageNo: number;
  ttsManufacturerName?: string;
}): Promise<Result<TTSInfo[]>> => {
  return $http.get({
    url: '/icms/ttsmanufacturermanage/ttsmanufacturers',
    data,
  });
};

/**根据TTS厂商id查询name */
export const getTTSInfo = (id: number): Promise<Result<TTSInfo>> => {
  return $http.get({
    url: `/icms/ttsmanufacturermanage/ttsmanufacturers/${id}`,
  });
};

/**合成TTS语音 */
export const createSyntheticTTSVoice = (data: SyntheticTTSVoice): Promise<any> => {
  return $http.post(
    {
      url: '/robotmanage/voices/synthesisvoice',
      data: data,
    },
    {
      responseType: 'blob', // 声明返回blob格式
      onDownloadProgress: (progress: any) => {
        // 下载接口
        console.log(progress, '下载接口');
        // console.log(Math.round((progress.loaded / progress.total) * 100) + "%");
      },
    }
  );
};
